<!DOCTYPE html>
<html>

<head>
    {include file='Public/head'} {block name='style'}{/block}
</head>

<body class="hold-transition skin-blue sidebar-mini">
    <div class="wrapper">
        {include file='Public/header'}
        <aside class="main-sidebar">
            <section class="sidebar">
                <div class="user-panel">
                    <div class="pull-left image">
                        <img src="__STATIC__/dist/img/user2-160x160.jpg" class="img-circle" alt="User Image">
                    </div>
                    <div class="pull-left info">
                        <p>{$admininfo['name']}</p>
                        <a href="#">{$admininfo['group']}</a>
                    </div>
                </div>
                <!-- <form action="#" method="get" class="sidebar-form">
                    <div class="input-group">
                        <input type="text" name="q" class="form-control" placeholder="搜索...">
                        <span class="input-group-btn">
                <button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i>
                </button>
              </span>
                    </div>
                </form> -->
                <ul class="sidebar-menu" data-widget="tree">
                    <li class="header">管理菜单</li>
                    <li class="{if $_SERVER['REDIRECT_URL'] === '/manager/index' || $_SERVER['REDIRECT_URL'] === '/manager/index.html' || $_SERVER['REDIRECT_URL'] === '/manager'} active {/if}">
                        <a href="/manager">
                            <i class="fa fa-home"></i> <span>首页</span>
                        </a>
                    </li>
                    {foreach name="startRoute" item='var'}
                    <?php
          $routeRes = routeAnalysis($var['id']);
        ?>
                        <li class="{:empty($routeRes)?'':'treeview'} {if strstr($_SERVER['REDIRECT_URL'],'/manager/'.$var['code']) !== false} active {/if}">
                            <a href="{:vali_data('url',$var['code'])?$var['code']:'/manager/'.$var['code']}" {:vali_data( 'url',$var[ 'code'])? 'target="_blank"': ''}>
                                <i class="fa {$var.icon}"></i>
                                <span>{$var.title}</span> {if !empty($routeRes)}
                                <span class="pull-right-container">
                                <i class="fa fa-angle-left pull-right"></i>
                              </span> {/if}
                            </a>
                            {if !empty($routeRes)}
                            <ul class="treeview-menu">
                                {foreach name="routeRes" item='v'}
                                <li class="{if $_SERVER['REDIRECT_URL'] === '/manager/'.$var['code'].'/'.$v['code'] || $_SERVER['REDIRECT_URL'] === '/manager/'.$var['code'].'/'.$v['code'].'.html'} active {/if}"><a href="/manager/{$var.code}/{$v.code}"><i class="fa {$v.icon}"></i> {$v.title}</a></li>
                                {/foreach}
                            </ul>
                            {/if}
                        </li>
                        {/foreach}
                </ul>
            </section>
        </aside>

        <div class="content-wrapper">
            {if $_SERVER['REDIRECT_URL'] !== '/manager/index' && $_SERVER['REDIRECT_URL'] !== '/manager/index.html' && $_SERVER['REDIRECT_URL'] !== '/manager'}
            <section class="content-header">
                <h1>
                    {$nowStart.child.title?$nowStart.child.title:$nowStart.title}
                    <!-- <small>{$nowStart.child.title}</small> -->
                </h1>
                <ol class="breadcrumb">
                    <li><a href="/manager"><i class="fa fa-dashboard"></i> 首页</a></li>
                    <li><a href="/manager/{$nowStart.code}">{$nowStart.title}</a></li>
                    <li class="active"><a href="/manager/{$nowStart.code}/{$nowStart.child.code}">{$nowStart.child.title}</a></li>
                </ol>
            </section>
            {/if} {block name='content'}{/block}
        </div>
        {include file='Public/footer'} {include file='Public/aside'}
    </div>
    {block name='modal'}{/block} {include file='Public/script'} {block name='js'}{/block}
    <script>
        //统一调用启用时间范围
        $('.datetime-range').daterangepicker({
            'opens': 'right',
            'singleDatePicker': false,
            'linkedCalendars': false,
            'startDate': moment().subtract(30, 'years'),
            'endDate': moment(new Date()),
        });
        $('.datetime-range.month').daterangepicker({
            'opens': 'right',
            'singleDatePicker': false,
            'linkedCalendars': false,
            'startDate': moment().subtract(30, 'days'),
            'endDate': moment(new Date()),
        });
        //统一调用时间选择
        $('.datepicker').daterangepicker({
          autoclose: true,
          singleDatePicker: true,
        })

        //自定义 dataTable 数据筛选
        //全局搜索
        function filterGlobal() {
            $('.tableData').DataTable().search(
                $('.global_filter').val()
            ).draw();
        }
        //单列关键字搜索
        function filterColumn(i) {
            $('.tableData').DataTable().column(i).search(
                $('.col' + i + '_filter').val()
            ).draw();
        }
        //时间范围筛选
        function filterDatetime(i) {
            let datetimes = $('.col' + i + '_filter').val();
            start = datetimes.split(' - ')[0],
                end = datetimes.split(' - ')[1];
            $.fn.dataTable.ext.search.push(
                function(settings, data, dataIndex) {
                    var min = start + ' 00:00:00';
                    var max = end + ' 23:59:59';
                    var date = data[i] || 0;
                    min = new Date(min.replace(/-/g, "\/"));
                    max = new Date(max.replace(/-/g, "\/"));
                    date = new Date(date.replace(/-/g, "\/"));
                    if ((isNaN(min) && isNaN(max)) || (isNaN(min) && date <= max) || (min <= date && isNaN(max)) || (min <= date && date <= max)) {
                        return true;
                    }
                    return false;
                }
            );
            $('.tableData').DataTable().draw();
        }
        //统一调用搜索
        function searchInit() {
            if ($('.global_filter').length >= 1) {
                filterGlobal($('.global_filter'));
            }
            if ($('.column_filter').length >= 1) {
                $('.column_filter').each(function(i, e) {
                    filterColumn($(e).data('column'));
                })
            }
            if ($('.datetime_filter').length >= 1) {
                filterDatetime($('.datetime_filter').data('column'));
            }
        }
        $(function() {
            //进入执行默认搜索项
            searchInit();
            //执行搜索
            $('.serchBtn').click(function() {
                searchInit();
            });
        })
    </script>

</body>

</html>